package com.example.demo.controller;

import com.example.demo.entity.Test;
import com.example.demo.service.TestService;
import com.example.demo.util.HttpAPIService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController {
    @Autowired
    private TestService testService;

    @Autowired
    private HttpAPIService httpAPIService;

    private final static String host = "localhost:8080";
    private final static String path = "test.po";


    @RequestMapping("/test")
    public List<Test> test(){
        //调用它方接口
        try {
            String result = httpAPIService.doPostByJsonParm(host + path, "ac");
            //不为空则，转成对象返回
            if (StringUtils.isNotEmpty(result)) {
                //转成对象
                String xss = result;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return testService.queryAllUsers();
    }

    @RequestMapping("/redisTest")
    public List<Test> redisTest(){
        //RedisClient.set
        return testService.queryAllUsers();
    }



}
